﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;

namespace Photography
{
    public static class UrlUtilities
    {
        private static log4net.ILog Logger { get { return log4net.LogManager.GetLogger(typeof(UrlUtilities)); } }

        private static string Host { get { return HttpContext.Current.Request["HOST"]; } }
        private static int IndexOfDotInHostString { get { return Host.IndexOf("."); } }

        public static bool IsSubDomainHost { get { return IndexOfDotInHostString > 0; } }

        public static string SubDomain
        {
            get
            {
                if (IsSubDomainHost)
                    return Host.Substring(0, IndexOfDotInHostString);
                else
                    return "www";
            }
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            /*routes.MapPageRoute("", "/", "~/", true, null, new RouteValueDictionary { { "", "" }, { "", "" } });

            if (IsSubDomainHost)
                routes.MapPageRoute("default", String.Empty, "~/site/default.aspx");
            else
                routes.MapPageRoute("default", String.Empty, "~/site/subdomain/default.aspx");*/
        }
    }
}